<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const xhr = new XMLHttpRequest();
      xhr.open("POST", "http://127.0.0.1:3000/login");
      xhr.setRequestHeader("Content-Type", "application/json");
      xhr.responseType = "json";
      xhr.onload = function () {
        console.log(xhr.response);
      };
      // 发送请求
      xhr.send(
        JSON.stringify({
          username: "lucy",
          password: "123123",
        })
      );
    </script>
  </body>
</html>
